package me.zfz.base.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import me.zfz.base.context.ISmartContext;
import me.zfz.base.service.SmartContextService;
import me.zfz.business.ISmartWeb;
import me.zfz.business.SmartWeb;

/**
 * spring初始化结束后执行该类
 * @author author
 *
 */
@Component
public class InitSpringComplete implements ApplicationListener<ContextRefreshedEvent>{

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		ApplicationContext context = event.getApplicationContext();
		if(null != context && null == context.getParent()) {
			ISmartContext smartContext = new SpringSmartContext(context);
			SmartContextService.setContext(smartContext);
			ISmartWeb smartWeb = new SmartWeb();
			smartWeb.initSystem();
		}
	}

}
